package com.weiqk.pmdemo.dao;

import com.weiqk.pmdemo.pojo.ApplyLink;
import com.weiqk.pmdemo.pojo.Dic;
import com.weiqk.pmdemo.pojo.Project;
import com.weiqk.pmdemo.pojo.Purchase;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface PurchaseRepository extends PagingAndSortingRepository<Purchase,Integer> {
    //通过id查找project
    @Query(value = "select * FROM PM_PURCHASE where PROJECT_ID=:n",nativeQuery = true)
    List<Purchase> findOneById(@Param("n") int id);

    @Query(value = "select * FROM PM_PURCHASE where COMPLETE_FLAG=0",nativeQuery = true)
    List<Purchase> findfalgnull();

    @Query(value = "select * FROM PM_PURCHASE where PURCHASE_ID=:n",nativeQuery = true)
    Purchase findOne(@Param("n") int id);

//    @Query(value = "select * FROM PM_PURCHASE where COMPLETE_FLAG=0",nativeQuery = true)
//    List<Purchase> findpay();
//
//    @Query(value = "select * FROM PM_PURCHASE where COMPLETE_FLAG=0",nativeQuery = true)
//    List<Purchase> findnullpay();
    @Query(value = "select ACTUAL_AMOUNT FROM PM_PURCHASE where PURCHASE_ID=:n",nativeQuery = true)
        int findAproject(@Param("n") int id);
}
